class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        res = 0 # 利润
        a,b,c = 0, 0, 1 # 买入，卖出前一天，卖出
        while c < len(prices):
            if prices[c] < prices[a]:
                a = c
                b = a
            elif prices[c] > prices[b]:
                res = max(res, prices[c] - prices[a])
                b = c
            c += 1
        return res